home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Events / Tick.h < prev    next >
Text File  |  1997-06-28  |  1KB  |  45 lines

  1. // Tick.h
  2.  
  3. #ifndef Tick_h
  4. #define Tick_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class Tick
  11.   {
  12.     private:
  13.         int32 time;
  14.     
  15.     public:
  16.         Tick( uint32 t )    : time( t )        {}
  17.         
  18.         int32 Time() const                    { return time; }
  19.  
  20.         static Tick Now()                        { return TickCount(); }
  21.         
  22.         void operator+=( int32 d )            { time += d; }
  23.         void operator-=( int32 d )            { time -= d; }
  24.         
  25.         Tick operator+( int32 d ) const    { return time + d; }
  26.         Tick operator-( int32 d ) const    { return time - d; }
  27.  
  28.         int32 operator-( Tick t ) const    { return time - t.time; }
  29.         
  30.         bool operator==( Tick t ) const    { return time == t.time; }
  31.         bool operator!=( Tick t ) const    { return time != t.time; }
  32.         
  33.         // We avoid the ordinary comparisons here so that we
  34.         // can compare times (locally) around the time when
  35.         // TickCount overflows. 
  36.         bool operator<=( Tick t ) const    { return time - t.time <= 0; }
  37.         bool operator>=( Tick t ) const    { return time - t.time >= 0; }
  38.         bool operator<( Tick t ) const    { return time - t.time < 0; }
  39.         bool operator>( Tick t ) const    { return time - t.time > 0; }
  40.         
  41.         void WaitFor() const;
  42.   };
  43.  
  44. #endif
  45.